#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : bigDataProject 
@File    : table_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/11/14 10:53 
@Describe: POS台位相关接口
"""
from api.pos_api.base_pos_api import BasePosAPI


class TableAPI(BasePosAPI):
    def table_list(self, operate=''):
        """
        台位列表
        :param operate: 台位操作: 1-换台, 2-并台, 3-搭台, 4-拆台, 5-退台, 6-锁台, 7-解锁 0-空台
        :return: response
        """
        payload = '{"operate":"' + operate + '"}'
        response = self.http_request('table/list', payload, 'POS台位列表')
        return response

    def table_repeal(self, table_code):
        """
        台位退台
        :param table_code: 台位编码
        :return: response
        """
        payload = '{"reasonCode":"back-01","tableCode":"' + table_code + '"}'
        response = self.http_request('table/repeal', payload, 'POS台位退台')
        return response

    def table_open(self, table_code, people_num='5'):
        """
        台位开台
        :param table_code: 台位号
        :param people_num: 用餐人数
        :return: response
        """
        payload = '{"tableCode":"' + table_code + '","peopleNum":"' + people_num + '"}'
        response = self.http_request('table/open', payload, 'POS台位开台')
        return response


if __name__ == '__main__':
    from utils.common.common_control import get_json_result

    table_api = TableAPI("823882", "sit")
    table_list = table_api.table_list('5')
    print(get_json_result(table_list, "$.data..orderNo"))
